<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>新增用户信息</h2>
    </div>
    <form action="{:U()}" method="post" class="form-horizontal">
      <div class="form-item">
      <input value="{$info.id}" name="id" type="hidden">
            <label class="item-label">姓名<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="uname" value="{$info.uname}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">手机号码<span class="check-tips">（关联用户注册手机号码）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="phone" value="{$info.phone}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">头像<span class="check-tips"></span></label>
            <div class="controls">
              <div style="border: 1px solid black;width: 100px;height: 100px">
              <img class='show-photo' src='{$info.photo}'>
              </div>
            <input type="hidden" name='' id='textfield' class='txt' />  
              <input type="hidden" name='photo' id='photo-val' class='txt' value="{$info.photo}"/>  
            <span onclick="file.click()" class="mybtn">浏览...</span>  
            <input type="file" name="file" class="file" id="file" size="28" onchange="document.getElementById('textfield').value=this.value" />  
            <span onclick="UpladFile()" class="mybtn">点我上传</span>  

            </div>
        </div>
        
        <div class="form-item">
            <label class="item-label">年龄<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="age" value="{$info.age}">
            </div>
        </div>
   
   <div class="form-item">
            <label class="item-label">国籍<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="nationality" value="{$info.nationality}">
            </div>
        </div>
        
          <div class="form-item">
            <label class="item-label">城市<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="city" value="{$info.city}">
            </div>
        </div>
   
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
    

    
      <script type="text/javascript">  
            var xhr;  
  
            function createXMLHttpRequest() {  
                if (window.ActiveXObject) {  
                    xhr = new ActiveXObject("Microsoft.XMLHTTP");  
                } else if (window.XMLHttpRequest) {  
                    xhr = new XMLHttpRequest();  
                }  
            }  
  
            function UpladFile() {  
                var fileObj = document.getElementById("file").files[0];  
                var FileController = '/ajaxupload.php';  
                var form = new FormData();  
                form.append("myfile", fileObj);  
                createXMLHttpRequest();  
                xhr.onreadystatechange = handleStateChange;  
                xhr.open("post", FileController, true);  
                xhr.send(form);  
            }  
  
            function handleStateChange() {  
                if (xhr.readyState == 4) {  
                    if (xhr.status == 200 || xhr.status == 0) {  
                        var result = xhr.responseText;  
                        var json = eval("(" + result + ")");  
                       $('.show-photo').attr('src', json.file);
                       $('#photo-val').val(json.file);
                      
                    }  
                }  
            }  
        </script>  
    
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('User/index')}');
    </script>
</block>
